package bch.kafka.integrate.test;

import com.google.common.collect.Maps;
import org.javers.core.Changes;
import org.javers.core.Javers;
import org.javers.core.JaversBuilder;
import org.javers.core.diff.Diff;
import org.javers.core.diff.custom.BigDecimalComparatorWithFixedEquals;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class JaversDemo {

    public static void main(String[] args) {
        Address addr1 = new Address("成都", "锦江区");
        Address addr2 = new Address("成都", "武侯区");

        // collection need index to compare
        User u1 = new User("张三", 18, addr1, List.of("football", "basketball", "swimming"), LocalDateTime.now(), new BigDecimal("100.00"));
        User u2 = new User("张三", 20, addr2, List.of("football", "swimming"), LocalDateTime.now().minusSeconds(1), new BigDecimal("100"));

        Javers javers = JaversBuilder.javers()
                .build();
        Diff diff = javers.compare(u1, u2);

        System.out.println(diff.prettyPrint());
    }

    record User(String name, int age, Address address, List<String> hobbies, LocalDateTime createdAt,
                BigDecimal salary
    ) {
    }

    record Address(String city, String district) {
    }
}
